import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/widgets.dart';

import '../home_page/page.dart';
import '../me_page/page.dart';

import 'action.dart';
import 'state.dart';

Effect<IndexPageState> buildEffect() {
  return combineEffects(<Object, Effect<IndexPageState>>{
    Lifecycle.initState: _onInit,
  });
}

void _onInit(dynamic action, Context<IndexPageState> ctx) {
  final state = IndexPageState(
    activeIndex: 0,
    pages: <Widget>[
      HomePage().buildPage(null),
      MePage().buildPage(null),
    ],
  );

  ctx.dispatch(IndexPageActionCreator.init(state));
}
